<?php
/*

Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
/**
	list_pages.php
	1. just list currently available pages
*/

$SEMF_ROOT = "../../";

$module_name = $_GET['module'];
$project_home = $_GET['project_home'];

// Define that we are returning XML content & not to cache:
header('Content-Type: text/xml');
header('Cache-control: no-cache');

//echo $module_name;
$module_home = $SEMF_ROOT.$project_home.$module_name."/";

$page_id = 0;
$pages = array();
$d = dir($module_home);
// Loop through all of the files:
$i = 0;
while(false !== ($file = $d->read())) 
{
	// If the file is not this file, and does not start with a '.' or '~'
	//echo $relative_path;
	if(($file{0} != '.') &&
		 ($file{0} != '~') &&
		 (substr($file, -3) == 'xml'))//only xml files are considered..
	{
		if($file == "module.xml") //ignore module.xml
		{
			continue;
		}
		$pos = strpos($file, ".xml");
		$pages[$i++] = substr($file, 0, $pos);
	}
}
?>
<style type="text/css">
<!--
.style_table {
	color: #003399;
	font-weight: bold;
	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-style: italic;
}
-->
</style>
<div style="padding:20px ;">
<div style="padding:5px;">
<img  width="71" height="25" src="../lib/images/addpagelightblue.png" onmouseover="javascript:changeImage(this,'addpageblack.png');" onmouseout="javascript:changeImage(this,'addpagelightblue.png');" onmousedown="javascript:changeImage(this,'addpagegreen.png');" onclick="javascript:addPageMode('<?php echo $module_name ?>', '<?php echo $project_home ?>');"/>
</div>
<table id="module_table" width="486" cellpadding="0" cellspacing="2" bgcolor="#000066" style="margin:10px">
  <?php
	foreach ( $pages as $page )
	{

echo '<tr class="style_table" style="background-image:url(../lib/images/menuidle2.png);" onmouseover="javacript:setBg(this,\'activemenu.png\');"  onmouseout="javascript:setBg(this,\'menuidle2.png\');" > 
<td width="160" >'.$page.'</td>
<td width="111"><img width="71" height="25" src="../lib/images/renamelightblue.png" onmouseover="javascript:changeImage(this,\'renameblue.png\');" onmouseout="javascript:changeImage(this,\'renamelightblue.png\');" onmousedown="javascript:changeImage(this,\'renamegreen.png\');" onclick="javascript:editPageMode(\''.$page.'\',\''.$module_name.'\',\''.$project_home.'\');"/></td>
<td width="104" ><img width="71" height="25" src="../lib/images/deletelightblue.png" onmouseover="javascript:changeImage(this,\'deletered.png\');" onmouseout="javascript:changeImage(this,\'deletelightblue.png\');" onmousedown="javascript:changeImage(this,\'deletegreen.png\');" onclick="javascript:deletePage(\''.$page.'\',\''.$page_id.'\',\''.$module_name.'\',\''.$project_home.'\');" /></td>
<td width="91" ><img width="71" height="25" src="../lib/images/editpagelightblue.png" onmouseover="javascript:changeImage(this,\'editpageblack.png\');" onmouseout="javascript:changeImage(this,\'editpagelightblue.png\');" onmousedown="javascript:changeImage(this,\'editpagegreen.png\');" onclick="javascript:editPage(\''.$page.'\',\''.$page_id.'\',\''.$module_name.'\',\''.$project_home.'\');" /></td>
</tr>';
		
		$page_id ++;
	}
?>
</table>
<?php
if( $page_id == 0 )
{
?>
<div id="notables" style="color:#990000;  margin:10px; "> <i>There are no Pages. To add a new table<b> Click</b> add new</i> </div>
<?php
}
?>
</div>
